package com.hp.bon.sgw.wh.channel.common;

import java.util.HashMap;
import java.util.Map;

import com.alipay.api.internal.util.StringUtils;

public class BizParam {

    private Map<String, Object> params = new HashMap<>();

    public void setParam(String key, Object value) {
        params.put(key, value);
    }

    public Object getParam(String key) {
        return params.get(key);
    }

    public String getParamString(String key) {
        String value = String.valueOf(params.get(key));
        if ("null".equals(value)) {
            value = null;
        }
        return value;
    }

    public Map<String, Object> getParams() {
        return params;
    }

    public Integer getParamInteger(String key) {
        String tempValue = String.valueOf(params.get(key));
        if (StringUtils.isEmpty(tempValue)) {
            return null;
        }
        return Integer.valueOf(tempValue);
    }

    public Long getParamLong(String key) {
        Object tempValue = params.get(key);
        if (tempValue instanceof Long) {
            return (Long) tempValue;
        }
        if (null == tempValue) {
            return null;
        }
        if (StringUtils.isEmpty(tempValue.toString())) {
            return null;
        }
        return Long.valueOf(tempValue.toString());
    }

}
